<%@page language="java" pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: ASUS
  Date: 2017/11/7
  Time: 15:07
  To change this template use File | Settings | File Templates.
--%>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
    function isWin(happyid) {
        //构造一个发送给服务端的参数列表
        var postData = {id:happyid};
        $.ajax({
            url:"happyAction_isWin.action",
            type:'POST',
            data:postData,
            dataType:'json',//服务端返回类型
            success:function (myresult) {
                alert(myresult.data);
                if (myresult.data==true){
                    alert('恭喜你获奖了');
                }else{
                    alert('恭喜你,输了!');
                }
            },
            timeout:3000,
            error:function(){
                alert('访问服务端失败')
            }
        });
    }
</script>
<html>
<head>
    <title>Title</title>

</head>
<body>
<table align="center" cellspacing="0" cellpadding="0" border="1" width="40%">
    <tr>
        <td>编号</td>
        <td>名字</td>
        <td>性别</td>
        <td>年龄</td>
        <td>状态</td>
        <td>是否获奖</td>
    </tr>
    <c:forEach items="${happyList}" var="hh">
        <tr>
            <td>${hh.id}</td>
            <td>${hh.name}</td>
            <td>${hh.sex}</td>
            <td>${hh.age}</td>
            <td>${hh.status}</td>
            <td onclick="isWin(${hh.id})">访问</td>
        </tr>
    </c:forEach>
</table>
</body>
</html>
